package com.hottv.meeting.videomeeting.module.edp;

import android.content.Context;
import android.util.Log;

import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

/**
 * Created by chengwenqiang on 2019/6/4.
 */

public class EDPControl {

    public static final MediaType JSON
            = MediaType.parse("application/json; charset=utf-8");
    private static OkHttpClient client =new OkHttpClient() ;
    private static Gson gson = new Gson();
    private static String URL = "http://api.heclouds.com/register_de?register_code=XdslxZXJxY5cWLhE";

    public static void getDeviceAndKey(Context context, String deviceSN, String title, Callback callback)
    {
        Log.i(EDPConfig.TAG,"getDeviceAndKey");
        Map<String, Object> roomSpec = new HashMap<>();
        roomSpec.put("sn", deviceSN);
        roomSpec.put("title", title);
        RequestBody body = RequestBody.create(JSON, gson.toJson(roomSpec));
        Request request = new Request.Builder()
                .url(URL)
                .post(body)
                .build();
        Call call = client.newCall(request);
        call.enqueue(callback);
    }
}
